package com.etc;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

/**
 * @Auther: zhezhe
 * @Date: 2018/10/2218:22
 * @Description:
 */
public class JobTest {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {

        System.setProperty("HADOOP_NAME","root");
        System.setProperty("HADOOP_USER_NAME","root");

        Configuration conf = new Configuration();

        conf.set("mapred.job.tracker","master11:9000");
//
//        conf.set("mapreduce.framework.name","yarn");
//        conf.set("yarn.resourcemanager.hostname","master11");
//        conf.set("mapreduce.app-submission.cross-platform","true");

        Job job = Job.getInstance(conf);

        job.setMapperClass(DataMap.class);
        job.setReducerClass(DataReduce.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(Text.class);

        FileInputFormat.setInputPaths(job,new Path("hdfs://master11:9000//input/*"));
        FileOutputFormat.setOutputPath(job,new Path("hdfs://master11:9000////////output/test2" +
                ""));

        job.setNumReduceTasks(1);

        boolean res = job.waitForCompletion(true);

        System.exit(res?0:-1);

    }
}
